package com.zy.start.config;

import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Configuration;
import org.springframework.web.servlet.config.annotation.ResourceHandlerRegistry;
import org.springframework.web.servlet.config.annotation.WebMvcConfigurer;

@Configuration
public class MyWebAppConfig implements WebMvcConfigurer {


    String os = System.getProperty("os.name");

    //文件夹绝对路径
    @Value("${file.upload.root.abpath}")
    private String rootAbpath;

    //文件夹url
    @Value("${file.upload.root.urlpath}")
    private String rootUrlpath;

    @Value("${file.upload.root.uploadWindows}")
    private String uploadWindows;

    public MyWebAppConfig() {
//        System.out.println("MyWebAppConfig：注册进来了=====================");
    }

    @Override
    public void addResourceHandlers(ResourceHandlerRegistry registry) {

        registry.addResourceHandler(rootUrlpath).addResourceLocations("file:" + rootAbpath);
        registry.addResourceHandler("/**").addResourceLocations("classpath:/static/");

    }
}
